//
//  YTSelectStringShowView.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/23.
//

#import "YTSelectStringShowView.h"
#import "UIScrollView+EmptyDataSet.h"

@interface YTSelectStringShowView ()

@property (nonatomic ,strong) UIView * makeView;
@property (nonatomic ,assign) CGFloat viewH;

@property (nonatomic ,strong) UIButton * leftbtn;
@property (nonatomic ,strong) UIButton * rightbtn;

@property (nonatomic ,strong) BRStringPickerView * pickerView;
@property (nonatomic ,strong) void(^block)(NSString * str);
@property (nonatomic ,assign) int index;
@property (nonatomic ,strong) NSArray <NSString *>* dateArray;
@property (nonatomic ,strong) UIView * pickermakeview;

@end
@implementation YTSelectStringShowView


+ (void)showViewWithTitle:(NSString *)title andIndex:(int)index andDateArray:(NSArray <NSString *>*)dateArray andBlock:(void(^)(NSString * str))block{
    
    YTSelectStringShowView * view = [YTSelectStringShowView new];
    [[DTKTool getCurrentVC].view addSubview:view];
    view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    view.viewH = kwt(300) + KSafeAreaBottomHeight;
    view.block = block;
    view.index = index;
    view.dateArray = dateArray;
    UIView * makeView = [UIView new];
    view.makeView = makeView;
    makeView.backgroundColor = UIColor.whiteColor;
    makeView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, view.viewH);
    [view addSubview:makeView];
    [DTKTool BFYJ:kwt(15) andView:makeView andCorner:UIRectCornerTopLeft|UIRectCornerTopRight andSize: CGRectMake(0, 0 ,SCREEN_WIDTH, view.viewH)];
    
    //    view.userInteractionEnabled = YES;
    //    [view addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:view action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:view action:@selector(noclick)]];
    view.userInteractionEnabled = YES;
    [view addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:view action:@selector(dismiss)]];
    makeView.userInteractionEnabled = YES;
    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:view action:@selector(noclick)]];
    
    UILabel * titlab = [DTKTool labelWithText:title andFont:kCFont(18) andTextColor:KcolorHex(@"#424242")];
    [makeView addSubview:titlab];
    [titlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(20));
    }];
    
    
    UIButton * btn = [UIButton buttonWithType:0];
    [btn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    btn.addTarget(view,@selector(dismiss));
    [makeView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.height.offset(kwt(20));
        make.centerY.equalTo(titlab);
    }];
    
    UIView * buttonview = [UIView new];
    [makeView addSubview:buttonview];
    [buttonview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(kwt(63) + KSafeAreaBottomHeight);
    }];
    
    UIButton * qxbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qxbtn.backgroundColor = KcolorHex(@"#F0F2F4");
    [qxbtn setTitle:@"取消" forState:UIControlStateNormal];
    [qxbtn setTitleColor:KcolorHex(@"#5A6066") forState:UIControlStateNormal];
    qxbtn.titleLabel.font = kCFont(17);
    [DTKTool YJ:kwt(5) andView:qxbtn];
    [qxbtn addTarget:view action:@selector(leftBtnclick) forControlEvents:UIControlEventTouchUpInside];
    [buttonview addSubview:qxbtn];
    [qxbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(kwt(44));
        make.width.offset(kwt(160));
        make.left.offset(kwt(20));
        make.top.offset(kwt(17));
    }];
    
    UIButton * qrbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    qrbtn.backgroundColor = [UIColor gradientColorWithSize:CGSizeMake(kwt(160), 1) direction:GradientColorDirectionLevel startColor:KcolorHex(@"#427FFF") endColor:KcolorHex(@"#3D5FFF")];
    [qrbtn setTitle:@"确定" forState:UIControlStateNormal];
    [qrbtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    qrbtn.titleLabel.font = kCFont(17);
    [DTKTool YJ:kwt(5) andView:qrbtn];
    [qrbtn addTarget:view action:@selector(rightbtnclick) forControlEvents:UIControlEventTouchUpInside];
    [buttonview addSubview:qrbtn];
    [qrbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(kwt(44));
        make.width.offset(kwt(160));
        make.right.offset(kwt(-20));
        make.top.offset(kwt(17));
    }];
    
    UIView * pickermakeview = [UIView new];
    view.pickermakeview = pickermakeview;
    [view addSubview:pickermakeview];
    [pickermakeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.offset(0);
        make.top.equalTo(makeView.mas_top).offset(kwt(50));
        make.bottom.equalTo(buttonview.mas_top);
    }];
    
    
    [view show];
    
    
}
- (void)addpickerviewWithView:(UIView *)view andIndex:(int)index andDateArray:(NSArray <NSString *>*)dateArray{
    BRStringPickerView * pickerView = [[BRStringPickerView alloc] initWithPickerMode:BRStringPickerComponentSingle];
    self.pickerView = pickerView;
    self.pickerView.dataSourceArr = dateArray;
    self.pickerView.selectIndex = index;
    MJWeakSelf
    //    pickerView.numberOfComponents = 3;
    pickerView.resultModelBlock = ^(BRResultModel * _Nullable resultModel) {
        NSLog(@"%@",resultModel);
        if(weakSelf.block){
            weakSelf.block(resultModel.value);
            [weakSelf dismiss];
        }
    };
    [pickerView addPickerToView:view];
    
}
- (void)leftBtnclick{
    [self dismiss];
    
}

- (void)rightbtnclick{
    //    [self dismiss];
    self.pickerView.doneBlock();
}


- (void)show{
    [[DTKTool getCurrentVC].view endEditing:YES];
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT - self.viewH , SCREEN_WIDTH, self.viewH);
    } completion:^(BOOL finished) {
        [self addpickerviewWithView:self.pickermakeview andIndex:self.index andDateArray:self.dateArray];
    }];
}
- (void)noclick{}
- (void)dismiss{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT , SCREEN_WIDTH, self.viewH);
    } completion:^(BOOL finished) {
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self removeFromSuperview];
    }];
}


@end

@interface YTSearchStringShowView()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>


@property (nonatomic ,strong) void(^block)(NSString * str);

@property (nonatomic ,strong) UIView * makeView;

@property (nonatomic ,assign) CGFloat viewH;

@property (nonatomic ,strong) NSArray <NSString *>* dateArray;
@property (nonatomic ,strong) NSArray <NSString *>* SSdateArray;
@property (nonatomic ,strong) NSString* ssStr;
@property (nonatomic ,strong) UIView * topview;
@property (nonatomic ,strong) UITableView * tableview;
@property (nonatomic ,strong) UIView * ssview;
@property (nonatomic ,strong) UITextField * sstextfield;
@property (nonatomic ,strong) UIButton * textRemovebtn ;
@end
@implementation YTSearchStringShowView
+ (void)showViewWithTitle:(NSString *)title andDateArray:(NSArray <NSString *>*)dateArray andBlock:(void(^)(NSString * str))block{
    
    YTSearchStringShowView * view = [YTSearchStringShowView new];
    view.dateArray = dateArray;
    view.block = block;
    [view setupviewWithTitle:title];
}
- (void)setupviewWithTitle:(NSString *)title{
    [[DTKTool getCurrentVC].view addSubview:self];
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    self.viewH = KSCREEN_HEIGHT - kwt(100);
    UIView * makeView = [UIView new];
    self.makeView = makeView;
    makeView.backgroundColor = KcolorHex(@"#F3F6F9");
    makeView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH,  self.viewH);
    [self addSubview:makeView];
    [DTKTool BFYJ:kwt(15) andView:makeView andCorner:UIRectCornerTopLeft|UIRectCornerTopRight andSize: CGRectMake(0, 0 ,SCREEN_WIDTH,  self.viewH)];
    
//    
//    makeView.userInteractionEnabled = YES;
//    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
//    self.userInteractionEnabled = YES;
//    [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismiss)]];
//    makeView.userInteractionEnabled = YES;
//    [makeView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(noclick)]];
    UILabel * toplab = [DTKTool labelWithText:title andFont:kCFont(18) andTextColor:KcolorHex(@"#242729")];
    [makeView addSubview:toplab];
    [toplab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(20));
    }];
    
    UIButton * btn = [UIButton buttonWithType:0];
    [btn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    btn.addTarget(self,@selector(dismiss));
    [makeView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.width.height.offset(kwt(20));
        make.centerY.equalTo(toplab);
    }];
    
    UIView * topview = [UIView new];
    self.topview = topview;
    topview.backgroundColor = UIColor.whiteColor;
    [makeView addSubview:topview];
    [topview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.offset(kwt(50));
        make.height.offset(kwt(65 + 2));
    }];
    MJWeakSelf
    UIView * btnview = [UIView new];
    btnview.addClickBlock(^{
        [weakSelf openSsbtnview];
    });
    [DTKTool YJBK:kwt(5) andView:btnview andWidth:1 andColor:KcolorHex(@"#D4D5DA")];
    [topview addSubview:btnview];
    [btnview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.top.offset(kwt(11));
        make.height.offset(kwt(40));
    }];
    
    UIImageView * btnviewimg = kimageView(@"program_search");
    [btnview addSubview:btnviewimg];
    [btnviewimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.centerY.offset(0);
        make.height.width.offset(kwt(16));
    }];
    
    UILabel * btnviewlab = [DTKTool labelWithText:@"请搜索" andFont:kFont(16) andTextColor:KcolorHex(@"#89908D")];
    [btnview addSubview:btnviewlab];
    [btnviewlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(40));
        make.centerY.offset(0);
    }];
    
    UIView * btnline = [UIView new];
    btnline.backgroundColor = KcolorHex(@"#EAEBED");
    [btnview addSubview:btnline];
    [btnline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(280));
        make.centerY.offset(0);
        make.width.offset(0.5);
        make.height.offset(kwt(28));
    }];
    
    UILabel * btnviewsslab = [DTKTool labelWithText:@"搜索" andFont:kCFont(16) andTextColor:KcolorHex(@"#0063FC")];
    [btnview addSubview:btnviewsslab];
    [btnviewsslab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-16));
        make.centerY.offset(0);
    }];
    

    UIView * topline = [UIView new];
    topline.backgroundColor = KcolorHex(@"#E7E7E7");
    [topview addSubview:topline];
    [topline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(kwt(2));
        make.bottom.left.right.offset(0);

    }];
    
  
    
    UIView * ssview = [UIView new];
    ssview.backgroundColor = UIColor.whiteColor;
    [makeView addSubview:ssview];
    self.ssview = ssview;
    [ssview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.offset(kwt(67));
    }];
    
    UIView * ssbuttomline = [UIView new];
    ssbuttomline.backgroundColor = KcolorHex(@"#EFEFEF");
    [ssview addSubview:ssbuttomline];
    [ssbuttomline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.bottom.offset(0);
        make.height.offset(kwt(2));
    }];
    UIButton * exitBtn = [UIButton buttonWithType:0];
    exitBtn.addTarget(self,@selector(openexitbtnview));
    exitBtn.addimg([UIImage imageNamed:@"left_black_path"]);
    [ssview addSubview:exitBtn];
    [exitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.centerY.offset(0);
        make.width.height.offset(kwt(20));
    }];
    
    UIView * ssbjview = [UIView new];
    [DTKTool YJBK:kwt(5) andView:ssbjview andWidth:1 andColor:KcolorHex(@"#1971CF")];
    [ssview addSubview:ssbjview];
    [ssbjview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(50));
        make.right.offset(kwt(-10));
        make.top.offset(kwt(11));
        make.height.offset(kwt(40));
    }];
    
    UIImageView * ssimg = kimageView(@"program_search");
    [ssbjview addSubview:ssimg];
    [ssimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.centerY.offset(0);
        make.height.width.offset(kwt(16));
    }];
    
    UITextField * sstextfield = [UITextField new];
    [sstextfield addTarget:self action:@selector(textFieldDidChangeValue:)  forControlEvents:UIControlEventEditingChanged];
    sstextfield.placeholder = @"请搜索";
    sstextfield.font = kFont(16);
    sstextfield.returnKeyType = UIReturnKeySearch;

    self.sstextfield = sstextfield;
    [ssbjview addSubview:sstextfield];
    [sstextfield mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(35));
        make.right.offset(kwt(-120));
        make.centerY.offset(0);
    }];
    
    UIButton * textRemovebtn = [UIButton buttonWithType:0];
    self.textRemovebtn = textRemovebtn;
    textRemovebtn.hidden = YES;
    textRemovebtn.addTarget(self,@selector(textRemovebtnClick));
    [textRemovebtn setImage:[UIImage imageNamed:@"search_delete"] forState:UIControlStateNormal];
    [ssbjview addSubview:textRemovebtn];
    [textRemovebtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(kwt(23));
        make.right.offset(kwt(-80));
        make.centerY.offset(0);
    }];
    
    
    UIView * ssline = [UIView new];
    ssline.backgroundColor = KcolorHex(@"#EAEBED");
    [ssbjview addSubview:ssline];
    [ssline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-65));
        make.centerY.offset(0);
        make.width.offset(0.5);
        make.height.offset(kwt(28));
    }];
    UIButton * ssbtn = [UIButton buttonWithType:0];
    ssbtn.addTarget(self,@selector(ssbtnClick));
    [ssbtn setTitle:@"搜索" forState:UIControlStateNormal];
    [ssbtn setTitleColor:KcolorHex(@"#0063FC") forState:UIControlStateNormal];
    ssbtn.titleLabel.font = kCFont(16);
    [ssbjview addSubview:ssbtn];
    [ssbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(0);
        make.left.equalTo(ssline);
        make.top.bottom.offset(0);
    }];
    
    UITableView * tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, kwt(115), SCREEN_WIDTH, SCREEN_HEIGHT - kwt(120)) style:UITableViewStyleGrouped];
    self.tableview = tableview;
    tableview.delegate = self;
    tableview.dataSource = self;
    tableview.backgroundColor =UIColor.whiteColor;
    tableview.emptyDataSetSource = self;
    tableview.emptyDataSetDelegate = self;
    tableview.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0.01)];
    tableview.sectionHeaderHeight = 0.01;
    tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
//    tableview.backgroundColor = UIColor.clearColor;
    
    [makeView addSubview:tableview];
    [tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.equalTo(topview.mas_bottom);
    }];
    
    [self openexitbtnview];
    [self show];
    
    
}

- (void)textRemovebtnClick{
    self.sstextfield.text = @"";
    self.textRemovebtn.hidden = YES;
    [self.tableview reloadData];
}
- (void)textFieldDidChangeValue:(UITextField *)sender{
    if(sender.markedTextRange == nil){
        NSLog(@"%@",sender.text);
        self.ssStr = sender.text;
        [self.tableview reloadData];
    }
    self.textRemovebtn.hidden = (sender.text.length == 0);

}

- (void)ssbtnClick{
    [self.sstextfield resignFirstResponder];
    [self.tableview reloadData];

}
- (NSArray<NSString *> *)SSdateArray{
    if(self.ssview.hidden){
        return self.dateArray;
    }
    NSMutableArray * array = [NSMutableArray array];
    for (NSString * str in self.dateArray) {
        if(self.ssStr.length > 0){
            if([str containsString:self.ssStr]){
                [array addObject:str];
            }
        } else {
            [array addObject:str];
        }
        
    }
    return array;;
}

- (void)openSsbtnview{
    self.ssview.hidden = NO;
    self.sstextfield.text = @"";
    self.textRemovebtn.hidden = YES;
    [self.sstextfield becomeFirstResponder];
    [self.tableview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(65));
    }];
}
- (void)openexitbtnview{
    self.ssview.hidden = YES;
    self.ssStr = @"";
    [self.sstextfield resignFirstResponder];
    [self.tableview reloadData];
    [self.tableview mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(117));
    }];
}


- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{ return YES; }
- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView {
    //加入你自定义的view
    UIView * noView = [UIView new];
    if( self.sstextfield.text.length > 0){
        UIView * NewnoView = [UIView new];
        //    NewnoView.backgroundColor = UIColor.whiteColor;
        [noView addSubview:NewnoView];
        [NewnoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_offset(KSCREEN_WIDTH);
            make.center.offset(0);
            make.height.mas_offset(KSCREEN_HEIGHT);
        }];
        UIImageView * noImage = [UIImageView new];
        [noView addSubview:noImage];
        noImage.image = [UIImage imageNamed:@"no_search"];
        [noImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_offset(0);
            make.centerY.mas_offset(-100);
        }];
        
        UILabel * noTitleLab = [UILabel new];
        [noView addSubview:noTitleLab];
        noTitleLab.text = @"暂无搜索记录\n换个关键词试试~";
        noTitleLab.numberOfLines = 2;
        noTitleLab.font = kFont(16);
        noTitleLab.textColor = [UIColor colorWithHexString:@"#44454C"];
        [noTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(noImage.mas_bottom).offset(30);
            make.centerX.mas_offset(0);
        }];
    }
    return noView;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return KSafeAreaBottomHeight;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.SSdateArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kwt(52);
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    YTSearchStringTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"YTSearchStringTableViewCell"];
    if (cell == nil) {
        cell = [[YTSearchStringTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YTSearchStringTableViewCell"];
    }
    if(self.SSdateArray.count > indexPath.row){
        cell.name = self.SSdateArray[indexPath.row];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell ;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(self.block){
        self.block(self.SSdateArray[indexPath.row]);
        [self dismiss];
    }
}

- (void)show{
    [[DTKTool getCurrentVC].view endEditing:YES];
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT - self.viewH , SCREEN_WIDTH, self.viewH);
    } completion:^(BOOL finished) {
    }];
}
- (void)noclick{}
- (void)dismiss{
    [UIView animateWithDuration:0.25 animations:^{
        self.makeView.frame = CGRectMake(0, SCREEN_HEIGHT , SCREEN_WIDTH, self.viewH);
    } completion:^(BOOL finished) {
        [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        [self removeFromSuperview];
    }];
}
@end

@interface YTSearchStringTableViewCell()
@property (nonatomic ,strong) UILabel * lab;
@end
@implementation YTSearchStringTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.whiteColor;
    self.contentView.clipsToBounds = YES;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;

    UILabel * lab = [DTKTool labelWithText:@"-" andFont:kFont(16) andTextColor:KcolorHex(@"#242729")];
    self.lab = lab;
    [self.contentView addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.offset(0);
    }];
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#E7E7E7");
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.height.offset(0.5);
        make.left.offset(kwt(15));
        make.right.offset(kwt(-15));

    }];
}
-(void)setName:(NSString *)name{
    self.lab.text = name;
}
 
@end
